import java.util.ArrayList;
import java.util.List;

public class B3 {

    // Define the states
    private static final int OUTSIDE_STRING = 0;
    private static final int INSIDE_STRING = 1;
    private static final int ESCAPE_MODE = 2;

    // Method to extract strings from source code
    public static List<String> extractStrings(String sourceCode) {
        List<String> result = new ArrayList<>();
        StringBuilder currentString = new StringBuilder();
        int state = OUTSIDE_STRING;

        for (int i = 0; i < sourceCode.length(); i++) {
            char ch = sourceCode.charAt(i);

            if (state == OUTSIDE_STRING) {
                if (ch == '"') {
                    state = INSIDE_STRING;
                }
                // No action needed for other characters outside a string
            } else if (state == INSIDE_STRING) {
                if (ch == '\\') {
                    state = ESCAPE_MODE;
                } else if (ch == '"') {
                    result.add(currentString.toString());
                    currentString.setLength(0); // Clear the StringBuilder
                    state = OUTSIDE_STRING;
                } else {
                    currentString.append(ch);
                }
            } else if (state == ESCAPE_MODE) {
                currentString.append(ch); // Append the escaped character
                state = INSIDE_STRING;
            }
        }

        // If the last state was INSIDE_STRING and there's an unclosed string,
        // we might want to handle it. For simplicity, assume all strings are correctly closed.
        // If needed, add error handling here (e.g., throw an exception if state != OUTSIDE_STRING).

        return result;
    }

    // Main method for testing
    public static void main(String[] args) {
        String sourceCode = "一般学习一门编程语言的时候，基本上第一个程序是输出\\\"Hello World!\\\"\n" +
                "另一个例子：\\\"This is a test\\\\nwith newline and tab\\\\t\\\"";

        List<String> strings = extractStrings(sourceCode);
        for (String s : strings) {
            System.out.println(s.replace("\\\"", "\"")); // Print strings with proper quotes for readability
        }
    }
}